package org.jspresso.testing.backend.action;

import java.util.Map;

import org.jspresso.framework.action.IActionHandler;
import org.jspresso.framework.application.backend.action.BackendAction;
import org.jspresso.model.Voyage;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;

public class Sample1BackAction extends BackendAction {
	@Override
	public boolean execute(IActionHandler actionHandler, final Map<String, Object> context) {
		
		final Voyage voyage = getActionParameter(context);
		
		getBackendController(context).getTransactionTemplate().execute(new TransactionCallbackWithoutResult() {
			@Override
			protected void doInTransactionWithoutResult(TransactionStatus status) {
				Voyage clonedVoyage = getBackendController(context).cloneInUnitOfWork(voyage);
				clonedVoyage.setRef("Test reference2");
			}
		});		
		return super.execute(actionHandler, context);
	}
}
